import { action, observable } from "mobx"
import {
    getUserInfo,// 获取用户信息
    getAuthCode,// 发送手机验证码
    logout,// 退出登录
    // changeInfo,// 更新用户信息接口
    fileUpload, //文件上传接口
    changeMobile// 修改手机号
} from "../../services/My"

import {
    search
} from "../../services/classfig"
class Mine {

    @observable
    info = {}
    @observable
    Code = ""
    @observable
    result = {}
    @observable
    codeOne = 0 
    async getUserInfo() {
        let InfoList = getUserInfo()
        this.info = await (await InfoList).data
    }
    @action // 发送手机验证码
    async sendCode(pop: string) {
        await getAuthCode(pop).then(res => {
            this.Code = res.data.authCode
        })
    }
    //changeInfo
    //退出登录
    @action
    async logout() {
        let aaa = await logout()
        this.codeOne = aaa.data.result
        // await logout().then(res=>{
        //     this.codeOne = res.data
        // })
    }

    async fileUpload(data: FormData){
        await fileUpload(data).then(res=>{
            console.log(res.data);
        })
    }

    @action//修改手机号
    async changeMobile(pop: string) {
        let obj = {
            authCode: this.Code,
            mobile: pop,
            mid: 'fa291cbd52aa40d2b47ba96c8ec59c99'
        }

        return await changeMobile(obj)
    }

    @action
    async keyword(data: string){
        await search(data).then(res=>{
            console.log(res.data);
        })
    }

}
export default Mine